<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #checkbox {
            display: none;
        }

        .on {
            color: #fff;
            display: none;
            text-indent: 5px;
            line-height: 28px;
        }

        .off {
            color: #fff;
            display: inline-block;
            text-indent: 45px;
            line-height: 28px;

        }

        .button {
            position: relative;
            display: inline-block;
            width: 70px;
            height: 30px;
            background-color: #E9E9E9;
            /* box-shadow: #ccc 0px 0px 0px 2px; */
            border-radius: 30px;
            overflow: hidden;
        }

        .circle {
            position: absolute;
            top: 0;
            left: 0;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background-color: #fff;
        }

        .button .text {
            line-height: 30px;
            font-size: 18px;
            text-shadow: 0 0 2px #ddd;
        }

        #checkbox:checked+label.button {
            background-color: #B4A078;
        }

        #checkbox:checked+label.button .circle {
            left: 40px;
        }

        #checkbox:checked+label.button .on {
            display: inline-block;
        }

        #checkbox:checked+label.button .off {
            display: none;
        }

        .button .circle {
            transition: all 0.3s;
        }
    </style>
</head>

<body>
    <div class="container">
        <input type="checkbox" id="checkbox" name="switch">
        <label for="checkbox" class="button">
            <span class="circle"></span>
            <span class="on">开</span>
            <span class="off">关</span>
        </label>
    </div>
</body>

</html>